<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Style Chooser</title>
    <script type="text/javascript" src="node_modules/jquery/dist/jquery.js"></script>
</head>
<body>

<textarea name="editor1" id="editor1" rows="10" cols="80">
    This is my textarea to be replaced with CKEditor.
</textarea>


<script>
    $(document).bind('paste', function (e) {
        if(window.clipboardData === undefined) {
            console.log(e.originalEvent.clipboardData.getData('Text'));
        } else {
            console.log(window.clipboardData.getData('Text'));
        }
    });

    document.addEventListener('paste', function (e) {
        if(window.clipboardData === undefined) {
            console.log(e.clipboardData.getData('Text'));
        } else {
            console.log(window.clipboardData.getData('Text'));
        }
    });

    var target = document.getElementById('editor1');
    setTimeout(function () {
        /*var VEvent = new KeyboardEvent('keydown', {key: 'v', code: 'KeyV', ctrlKey: true, location: 0, keyCode: 17, which: 17});
        var ctrlEvent = new KeyboardEvent('keydown', {key: 'Control', code: 'ControlLeft', location: 1, ctrlKey: true});
        target.dispatchEvent(ctrlEvent);
        target.dispatchEvent(VEvent);*/
        target.dispatchEvent(new ClipboardEvent('paste', {dataType: 'TEXT', data: '1111'}))
    }, 2000);

    target.addEventListener('keydown', function (e) {
        console.log('keydown', e);
    });

</script>

</body>
</html>